package com.itheima.service;

import com.itheima.dao.UserMapper;
import com.itheima.domain.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class UserService {
    public static void main(String[] args) throws IOException {
        InputStream resourceAsStream = Resources.getResourceAsStream ( "sqlMapConfig.xml" );
        SqlSessionFactory build = new SqlSessionFactoryBuilder ( ).build ( resourceAsStream );
        SqlSession sqlSession = build.openSession ( );
        UserMapper mapper = sqlSession.getMapper ( UserMapper.class );
        List <User> all = mapper.findAll ( );
        System.out.println (all );


        List <User> userList = mapper.findById ( 1 );
        System.out.println (userList );

    }
}